﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

partial class SqliteConnectionStringEditor : UserControl
{
    public SqliteConnectionStringEditor()
    {
        InitializeComponent();
    }

    public SqliteConnectionStringEditor(string connectionString)
    {
        InitializeComponent();

        SqliteConnectionStringBuilder builder = new SqliteConnectionStringBuilder(connectionString);

        tbFilepath.Text = builder.Source;
    }

    public override string ToString()
    {
        // http://www.connectionstrings.com/sqlite
        return string.Format("Data Source={0};Version=3;", tbFilepath.Text);
    }

    private void btnBrowse_Click(object sender, EventArgs e)
    {
        OpenFileDialog fDialog = new OpenFileDialog();
        fDialog.Title = "Open Sqlite File";
        fDialog.Filter = "Sqlite File(.db)|*.db";
        fDialog.InitialDirectory = @"C:\";
        if(fDialog.ShowDialog() == DialogResult.OK)
        {
            tbFilepath.Text = fDialog.FileName.ToString();
        }
    }
}
